#include <stdio.h>


int main() {
	char s[1000];
	scanf("%s", s);
	int n;
	scanf("%d", &n);

	int len = strlen(s);
	int dp[1000] ={ 0};

	int i=0;
	for(i=0;i<n;i++)
	{
		if( s[i]=='C' ||  s[i]=='G')
		{
			dp[n-1]++;
		}
	}

	// 
	int max = dp[n-1];
	int maxIdex = n-1;
	for(i=n;i<len;i++)
	{
		int out = 0;
		if(s[i-n]=='C' || s[i-n]=='G')
			out = 1;
		int in = 0;
		if(s[i]=='C' || s[i]=='G')
			in = 1;
		dp[i] = dp[i-1]+in - out;
		if(dp[i]>max)
		{
			max = dp[i];
			maxIdex = i;
		}
	}

	s[maxIdex+1] = '\0';

	printf("%s",s+maxIdex+1-n);
	return 0;
}